package partFour.homeWork.code.code03;

import java.io.File;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * 创建线程方式三，使用实现Callable接口来实现创建并启动线程
 */
public class FileCopyThread3Imp implements Callable {
    @Override
    public Object call() throws Exception {
        String targetPath = "./复制到的文件夹/";
        String originPath = "./源文件夹/";


        File file = new File(originPath);
        if (file.exists()) {
            FileCopy.dirCopy(targetPath,originPath);
        }else {
            System.out.println("复制的源文件路径不存在！，请确定是否输入的路径是否正确！");
        }

        return null;
    }

    public static void main(String[] args) {
        FileCopyThread3Imp fc = new FileCopyThread3Imp();
        FutureTask futureTask = new FutureTask(fc);
        Thread t1 = new Thread(futureTask);
        t1.start();
        try {
            Object o = futureTask.get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

    }
}
